﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.Flexibles.CApCableParametersUserControl
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Shapes;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;
using Tecnomatix.Engineering.Ui.WPF;
using UiInternalControls.WPFControls;


namespace DnProcessSimulateCommands.Flexibles;

public class CApCableParametersUserControl : UserControl, IComponentConnector
{
  private const double ForceParameterEpsilon = 0.01;
  private const double ParameterEpsilon = 0.0001;
  internal StackPanel parameterStackPanel;
  internal Grid parameterGrid;
  internal RowDefinition densityRow;
  internal RowDefinition fulcrumRow;
  internal RowDefinition maxTensionRow;
  internal RowDefinition maxTwistRow;
  internal RowDefinition minCurvatureRadiusRow;
  internal RowDefinition passNearRow;
  internal RowDefinition oscillationSliderRow;
  internal TextBlock textblockDensity;
  internal TxNumericEditBoxControl TxNumericEditBoxDensity;
  internal TextBlock textblockYoungsModulus;
  internal TxNumericEditBoxControl TxNumericEditBoxYoungsModulus;
  internal TextBlock labelCableFulcrumLength;
  internal TxNumericEditBoxControl TxNumericEditBoxFulcrumLength;
  internal TxInfoButton TxInfoButtonStartFulcumLenght;
  internal Grid tensionGrid;
  internal ColumnDefinition tensionColumn;
  internal Rectangle rectTensionViolationColor;
  internal TextBlock textblockMaxTension;
  internal TxNumericEditBoxControl TxNumericEditBoxMaxTension;
  internal Grid twistGrid;
  internal ColumnDefinition twistColumn;
  internal Rectangle rectTwistViolationColor;
  internal CheckBox textblockMaxTwist;
  internal TxNumericEditBoxControl TxNumericEditBoxMaxTwist;
  internal Grid contactForceGrid;
  internal ColumnDefinition contactForceColumn;
  internal Rectangle rectContactForceExcessViolationColor;
  internal CheckBox textblockMaxContactForce;
  internal TxNumericEditBoxControl TxNumericEditBoxMaxContactForce;
  internal Grid curvatureRadiusGrid;
  internal ColumnDefinition curvatureColumn;
  internal Rectangle rectBendingViolationColor;
  internal CheckBox textblockMinCurvatuceRadius;
  internal TxNumericEditBoxControl TxNumericEditBoxMinCurvatuceRadius;
  internal TextBlock labelCablePassNearFrame;
  internal TxObjEditBoxControl frameBoxCtrlPassNearFrameCable;
  internal Grid sliderOscillationGrid;
  internal TextBlock labelCableOscillation;
  internal TextBlock textBlockOscillationNone;
  internal Slider SliderOscillation;
  internal TextBlock textBlockOscillationFull;
  private bool _contentLoaded;

  public event TentativePropertyChangedEventHandler TentativePropertyChanged;

  public CApCableParametersUserControl() => this.IsControlLoading = true;

  private bool IsControlLoading { get; set; }

  public ICApFLEXCableAttributeViewModel AttributeViewModel { get; set; }

  public CApFLEXFrameValidator FrameValidator { get; set; }

  public ITxLocatableObject PassNearFrame { get; set; }

  public void InitControl()
  {
    this.InitializeComponent();
    this.AttributeViewModel.PropertyChanged += new PropertyChangedEventHandler(this.AttributeViewModel_PropertyChanged);
    TxApplication.Options.Units.LinearUnitsChanged += new TxUnitsOptions_LinearUnitsChangedEventHandler(this.Units_LinearUnitsChanged);
    TxApplication.Options.Units.MassUnitsChanged += new TxUnitsOptions_MassUnitsChangedEventHandler(this.Units_MassUnitsChanged);
    this.AttributeViewModel.FulcrumStepSize = this.ComputeFulcrumStepSize();
    this.AttributeViewModel.MinCurvatureStepSize = CApCableUtility.ComputeRadiusStepSize();
    this.InitNumEditorControl();
    this.InitNumEditorControlWithoutUnitDecimalPlace();
    this.InitViolationEmphasizeColors();
    this.InitFrameEditorBox();
  }

  private void InitNumEditorControl()
  {
    this.UpdateLinearUnitText();
    this.UpdateMassUnitText();
    this.textblockDensity.Text = $"{this.textblockDensity.Text} ({CApFLEXStringTable.DensityUnitString}):";
    this.textblockMaxTwist.Content = (object) $"{this.textblockMaxTwist.Content?.ToString()} ({CApFLEXStringTable.MaxTwistUnitString}):";
    this.textblockYoungsModulus.Text = $"{this.textblockYoungsModulus.Text} ({CApFLEXStringTable.YoungsModulusUnit}):";
    this.TxInfoButtonStartFulcumLenght.TooltipContent = (object) $"{CApFLEXStringTable.ToolTipStartEndFulcrum}\n{CApFLEXStringTable.ToolTipFulcrumCondition}";
  }

  private void InitNumEditorControlWithoutUnitDecimalPlace()
  {
    this.TxNumericEditBoxYoungsModulus.DecimalPlaces = 2;
    this.TxNumericEditBoxDensity.DecimalPlaces = 2;
    this.TxNumericEditBoxMaxTwist.DecimalPlaces = 2;
  }

  private void InitViolationEmphasizeColors()
  {
    BrushConverter brushConverter = new BrushConverter();
    byte num1 = TxFlxCableEx.TensionViolationEmphasizeColor.Red;
    string str1 = num1.ToString("x2");
    num1 = TxFlxCableEx.TensionViolationEmphasizeColor.Green;
    string str2 = num1.ToString("x2");
    num1 = TxFlxCableEx.TensionViolationEmphasizeColor.Blue;
    string str3 = num1.ToString("x2");
    string text1 = $"#{str1}{str2}{str3}";
    byte num2 = TxFlxCableEx.TwistViolationEmphasizeColor.Red;
    string str4 = num2.ToString("x2");
    num2 = TxFlxCableEx.TwistViolationEmphasizeColor.Green;
    string str5 = num2.ToString("x2");
    num2 = TxFlxCableEx.TwistViolationEmphasizeColor.Blue;
    string str6 = num2.ToString("x2");
    string text2 = $"#{str4}{str5}{str6}";
    byte num3 = TxFlxCableEx.ContactForceExcessViolationEmphasizeColor.Red;
    string str7 = num3.ToString("x2");
    num3 = TxFlxCableEx.ContactForceExcessViolationEmphasizeColor.Green;
    string str8 = num3.ToString("x2");
    num3 = TxFlxCableEx.ContactForceExcessViolationEmphasizeColor.Blue;
    string str9 = num3.ToString("x2");
    string text3 = $"#{str7}{str8}{str9}";
    byte num4 = TxFlxCableEx.BendingViolationEmphasizeColor.Red;
    string str10 = num4.ToString("x2");
    num4 = TxFlxCableEx.BendingViolationEmphasizeColor.Green;
    string str11 = num4.ToString("x2");
    num4 = TxFlxCableEx.BendingViolationEmphasizeColor.Blue;
    string str12 = num4.ToString("x2");
    string text4 = $"#{str10}{str11}{str12}";
    this.rectTensionViolationColor.Fill = (Brush) brushConverter.ConvertFromString(text1);
    this.rectTwistViolationColor.Fill = (Brush) brushConverter.ConvertFromString(text2);
    this.rectContactForceExcessViolationColor.Fill = (Brush) brushConverter.ConvertFromString(text3);
    this.rectBendingViolationColor.Fill = (Brush) brushConverter.ConvertFromString(text4);
  }

  public void InitFrameEditorBox()
  {
    this.frameBoxCtrlPassNearFrameCable.SetValidator((ITxValidator) this.FrameValidator);
    this.frameBoxCtrlPassNearFrameCable.Picked += new TxObjEditBoxCtrl_PickedEventHandler(this.FrameEditBoxCtrlPassNear_Picked);
    ((UIElement) this.frameBoxCtrlPassNearFrameCable).KeyUp += new KeyEventHandler(this.FrameBoxCtrlPassNearFrameCable_KeyUp);
    if (this.AttributeViewModel.PassNearFrame == null)
      return;
    this.frameBoxCtrlPassNearFrameCable.Object = (ITxObject) this.AttributeViewModel.PassNearFrame;
  }

  public void UpdateLinearUnitText()
  {
    this.labelCableFulcrumLength.Text = CApFLEXStringTable.CableFulcrumLengthLabel + CApCableUtility.LinearUnitLabelText();
    this.textblockMinCurvatuceRadius.Content = (object) (CApFLEXStringTable.CableMinCurvatureRadiusLabel + CApCableUtility.LinearUnitLabelText());
  }

  public void UpdateMassUnitText()
  {
    this.textblockMaxTension.Text = CApFLEXStringTable.CableMaxTensionLabel + CApCableUtility.MassUnitLabelText();
    this.textblockMaxContactForce.Content = (object) (CApFLEXStringTable.CableMaxContactForce + CApCableUtility.MassUnitLabelText());
  }

  private double ComputeFulcrumStepSize()
  {
    double fulcrumStepSize;
    switch ((int) TxApplication.Options.Units.LinearUnit)
    {
      case 0:
        fulcrumStepSize = 10.0;
        break;
      case 1:
        fulcrumStepSize = 1.0;
        break;
      case 2:
      case 3:
      case 4:
        fulcrumStepSize = 0.1;
        if (TxApplication.Options.Units.LinearDigitsAfterDecimalPoint == 0)
        {
          fulcrumStepSize = 1.0;
          break;
        }
        break;
      default:
        fulcrumStepSize = 1.0;
        break;
    }
    return fulcrumStepSize;
  }

  private void Units_LinearUnitsChanged(
    object sender,
    TxUnitsOptions_LinearUnitsChangedEventArgs args)
  {
    this.UpdateLinearUnitText();
  }

  private void Units_MassUnitsChanged(object sender, TxUnitsOptions_MassUnitsChangedEventArgs args)
  {
    this.UpdateMassUnitText();
  }

  private void AttributeViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
  {
    if (!(e.PropertyName == "PassNearFrame"))
      return;
    this.UnregisterAttachmentFrameNotifications();
    this.PassNearFrame = this.AttributeViewModel.PassNearFrame;
    this.RegisterAttachmentFrameNotifications();
  }

  private void RegisterAttachmentFrameNotifications()
  {
    if (this.PassNearFrame == null)
      return;
    ((ITxObject) this.PassNearFrame).NameChanged += new TxObject_NameChangedEventHandler(this.Frame_NameChanged);
    ((ITxObject) this.PassNearFrame).Deleted += new TxObject_DeletedEventHandler(this.Frame_Deleted);
  }

  private void UnregisterAttachmentFrameNotifications()
  {
    if (this.PassNearFrame == null)
      return;
    ((ITxObject) this.PassNearFrame).NameChanged -= new TxObject_NameChangedEventHandler(this.Frame_NameChanged);
    ((ITxObject) this.PassNearFrame).Deleted -= new TxObject_DeletedEventHandler(this.Frame_Deleted);
  }

  public bool AreParametersNumericalControlValid()
  {
    bool flag = false;
    if (this.TxNumericEditBoxYoungsModulus != null && this.TxNumericEditBoxDensity != null && this.TxNumericEditBoxMaxTension != null && this.TxNumericEditBoxMaxContactForce != null && this.TxNumericEditBoxMinCurvatuceRadius != null)
      flag = true;
    return flag;
  }

  public bool AreParametersNumericalControlTextValid()
  {
    return this.TxNumericEditBoxYoungsModulus.Text != "" && this.TxNumericEditBoxYoungsModulus.Text != "-" && this.TxNumericEditBoxDensity.Text != "" && this.TxNumericEditBoxFulcrumLength.Text != "" && this.TxNumericEditBoxMaxTension.Text != "" && this.TxNumericEditBoxMaxTwist.Text != "" && this.TxNumericEditBoxMaxContactForce.Text != "" && this.TxNumericEditBoxMinCurvatuceRadius.Text != "";
  }

  public bool IsMaxTensionEqual(double maxTension)
  {
    CApNewtonToKillogramConverter killogramConverter = new CApNewtonToKillogramConverter();
    try
    {
      return Math.Abs(maxTension - (double) killogramConverter.ConvertBack((object) (CApCableUtility.ConvertStringToDouble(this.TxNumericEditBoxMaxTension.Text) * TxApplication.Options.Units.MassMultiplier), this.TxNumericEditBoxMaxTension.GetType(), (object) this.TxNumericEditBoxMaxTension, CultureInfo.CurrentCulture)) < 0.01;
    }
    catch (FormatException ex)
    {
      return false;
    }
  }

  public bool IsDensityEqual(double density)
  {
    try
    {
      return Math.Abs(density - CApCableUtility.ConvertStringToDouble(this.TxNumericEditBoxDensity.Text)) < 0.0001;
    }
    catch (FormatException ex)
    {
      return false;
    }
  }

  public bool IsYoungsModulusEqual(double youngsModulus)
  {
    try
    {
      return Math.Abs(youngsModulus - CApCableUtility.ConvertStringToDouble(this.TxNumericEditBoxYoungsModulus.Text)) < 0.0001;
    }
    catch (FormatException ex)
    {
      return false;
    }
  }

  public bool IsFulcrumLengthEqual(double fulcrumLength)
  {
    CApNewtonToKillogramConverter killogramConverter = new CApNewtonToKillogramConverter();
    try
    {
      return Math.Abs(fulcrumLength - CApCableUtility.ConvertStringToDouble(this.TxNumericEditBoxFulcrumLength.Text) * TxApplication.Options.Units.LinearMultiplier) < 0.0001;
    }
    catch (FormatException ex)
    {
      return false;
    }
  }

  public bool IsMaxTwistEqual(double maxTwist)
  {
    CApRadianToDegreeConverter toDegreeConverter = new CApRadianToDegreeConverter();
    bool flag = !this.AttributeViewModel.IsMaxTwistAngleLimited;
    if (!flag)
    {
      try
      {
        flag = Math.Abs(maxTwist - (double) toDegreeConverter.ConvertBack((object) CApCableUtility.ConvertStringToDouble(this.TxNumericEditBoxMaxTwist.Text), this.TxNumericEditBoxMaxTwist.GetType(), (object) this.TxNumericEditBoxMaxTwist, CultureInfo.CurrentCulture)) < 0.0001;
      }
      catch (FormatException ex)
      {
        flag = false;
      }
    }
    return flag;
  }

  public bool IsContactForceEqual(double contactForce)
  {
    CApNewtonToKillogramConverter killogramConverter = new CApNewtonToKillogramConverter();
    bool flag = !this.AttributeViewModel.IsMaxContactForceLimited;
    if (!flag)
    {
      try
      {
        flag = Math.Abs(contactForce - (double) killogramConverter.ConvertBack((object) (CApCableUtility.ConvertStringToDouble(this.TxNumericEditBoxMaxContactForce.Text) * TxApplication.Options.Units.MassMultiplier), this.TxNumericEditBoxMaxContactForce.GetType(), (object) this.TxNumericEditBoxMaxContactForce, CultureInfo.CurrentCulture)) < 0.01;
      }
      catch (FormatException ex)
      {
        flag = false;
      }
    }
    return flag;
  }

  public bool IsCurvatureEqual(double curvRadius)
  {
    bool flag = !this.AttributeViewModel.IsMinCurvatureRadiusLimited;
    if (!flag)
    {
      try
      {
        flag = Math.Abs(curvRadius - CApCableUtility.ConvertStringToDouble(this.TxNumericEditBoxMinCurvatuceRadius.Text) * TxApplication.Options.Units.LinearMultiplier) < 0.0001;
      }
      catch (FormatException ex)
      {
        flag = false;
      }
    }
    return flag;
  }

  public void DidDialogClose()
  {
    this.AttributeViewModel.PropertyChanged -= new PropertyChangedEventHandler(this.AttributeViewModel_PropertyChanged);
    TxApplication.Options.Units.LinearUnitsChanged -= new TxUnitsOptions_LinearUnitsChangedEventHandler(this.Units_LinearUnitsChanged);
    TxApplication.Options.Units.MassUnitsChanged -= new TxUnitsOptions_MassUnitsChangedEventHandler(this.Units_MassUnitsChanged);
    this.UnregisterAttachmentFrameNotifications();
  }

  public void UpdateUserControl()
  {
    if (this.frameBoxCtrlPassNearFrameCable.Object == this.AttributeViewModel.PassNearFrame)
      return;
    this.frameBoxCtrlPassNearFrameCable.Object = (ITxObject) this.AttributeViewModel.PassNearFrame;
    if (this.frameBoxCtrlPassNearFrameCable.Object != null)
      return;
    this.frameBoxCtrlPassNearFrameCable.Text = "";
  }

  private void Frame_NameChanged(object sender, TxObject_NameChangedEventArgs args)
  {
    if (!(sender is ITxLocatableObject itxLocatableObject) || itxLocatableObject != this.PassNearFrame)
      return;
    this.frameBoxCtrlPassNearFrameCable.Text = ((ITxObject) itxLocatableObject).Name;
  }

  private void Frame_Deleted(object sender, TxObject_DeletedEventArgs args)
  {
    if (!(sender is ITxLocatableObject itxLocatableObject) || itxLocatableObject != this.PassNearFrame)
      return;
    this.AttributeViewModel.PassNearFrame = (ITxLocatableObject) null;
    this.frameBoxCtrlPassNearFrameCable.Text = "";
  }

  private void TxNumericEditBox_GotFocus(object send, RoutedEventArgs e)
  {
  }

  private void FrameEditBoxCtrlPassNear_Picked(object sender, TxObjEditBoxCtrl_PickedEventArgs args)
  {
    TxFrame txFrame = args.Object as TxFrame;
    CApCableUtility.UnHighlightObject((ITxDisplayableObject) (this.AttributeViewModel.PassNearFrame as TxFrame));
    CApCableUtility.UnHighlightObject((ITxDisplayableObject) (this.AttributeViewModel.StartFrame as TxFrame));
    CApCableUtility.UnHighlightObject((ITxDisplayableObject) (this.AttributeViewModel.EndFrame as TxFrame));
    CApCableUtility.UnHighlightObject((ITxDisplayableObject) (this.AttributeViewModel.PassNearFrame as TxFrame));
    if (TxFrame.op_Inequality(txFrame, (ITxObject) null))
    {
      if (args.IsValidObjectPicked)
      {
        this.AttributeViewModel.PassNearFrame = (ITxLocatableObject) txFrame;
        CApCableUtility.HighlightObject((ITxDisplayableObject) txFrame);
      }
      else
        this.AttributeViewModel.PassNearFrame = (ITxLocatableObject) null;
    }
    else
      this.AttributeViewModel.PassNearFrame = (ITxLocatableObject) null;
  }

  private void PassNearFrame_GotFocus(object sender, RoutedEventArgs e)
  {
    if (this.frameBoxCtrlPassNearFrameCable.Text != "")
      CApCableUtility.HighlightObject((ITxDisplayableObject) (this.AttributeViewModel.PassNearFrame as TxFrame));
    this.AttributeViewModel.FocusedPickableControl = PickableControlFocusStatus.PassNearFrame;
  }

  private void PassNearFrame_LostFocus(object sender, RoutedEventArgs e)
  {
    CApCableUtility.UnHighlightObject((ITxDisplayableObject) (this.AttributeViewModel.PassNearFrame as TxFrame));
    this.AttributeViewModel.FocusedPickableControl = PickableControlFocusStatus.None;
  }

  private void FrameBoxCtrlPassNearFrameCable_KeyUp(object sender, KeyEventArgs e)
  {
    if (e.Key != Key.Back && e.Key != Key.Delete || sender != this.frameBoxCtrlPassNearFrameCable)
      return;
    CApCableUtility.UnHighlightObject((ITxDisplayableObject) (this.AttributeViewModel.PassNearFrame as TxFrame));
    this.AttributeViewModel.PassNearFrame = (ITxLocatableObject) null;
    this.frameBoxCtrlPassNearFrameCable.Text = "";
  }

  private void TxNumericEditBoxYoungsModulus_TentativeValueChanged(
    object sender,
    TxNumericEditBoxCtrl_TentativeValueChangedEventArgs args)
  {
    if (this.IsControlLoading)
      return;
    this.AttributeViewModel.SeYoungsModulusNoEventSent(args.TentativeValue);
    TentativePropertyChangedEventHandler tentativePropertyChanged = this.TentativePropertyChanged;
    if (tentativePropertyChanged == null)
      return;
    tentativePropertyChanged((object) this);
  }

  private void TxNumericEditBoxDensity_TentativeValueChanged(
    object sender,
    TxNumericEditBoxCtrl_TentativeValueChangedEventArgs args)
  {
    if (this.IsControlLoading)
      return;
    this.AttributeViewModel.SetDensityNoEventSent(args.TentativeValue);
    TentativePropertyChangedEventHandler tentativePropertyChanged = this.TentativePropertyChanged;
    if (tentativePropertyChanged == null)
      return;
    tentativePropertyChanged((object) this);
  }

  private void TxNumericEditBoxFulcrumLength_TentativeValueChanged(
    object sender,
    TxNumericEditBoxCtrl_TentativeValueChangedEventArgs args)
  {
    if (this.IsControlLoading)
      return;
    this.AttributeViewModel.SetFulcrumNoEventSent(args.TentativeValue * TxApplication.Options.Units.LinearMultiplier);
    TentativePropertyChangedEventHandler tentativePropertyChanged = this.TentativePropertyChanged;
    if (tentativePropertyChanged == null)
      return;
    tentativePropertyChanged((object) this);
  }

  private void TxNumericEditBoxMaxTension_TentativeValueChanged(
    object sender,
    TxNumericEditBoxCtrl_TentativeValueChangedEventArgs args)
  {
    if (this.IsControlLoading)
      return;
    double num;
    try
    {
      num = (double) new CApNewtonToKillogramConverter().ConvertBack((object) (CApCableUtility.ConvertStringToDouble(this.TxNumericEditBoxMaxTension.Text) * TxApplication.Options.Units.MassMultiplier), this.TxNumericEditBoxMaxTension.GetType(), (object) this.TxNumericEditBoxMaxTension, CultureInfo.CurrentCulture);
    }
    catch (FormatException ex)
    {
      num = 0.0;
    }
    this.AttributeViewModel.SetMaxTentionNoEventSent(num);
    TentativePropertyChangedEventHandler tentativePropertyChanged = this.TentativePropertyChanged;
    if (tentativePropertyChanged == null)
      return;
    tentativePropertyChanged((object) this);
  }

  private void TxNumericEditBoxMaxTwist_TentativeValueChanged(
    object sender,
    TxNumericEditBoxCtrl_TentativeValueChangedEventArgs args)
  {
    if (this.IsControlLoading)
      return;
    this.AttributeViewModel.SetMaxTwistAngleNoEventSent(args.TentativeValue * TxApplication.Options.Units.AngularMultiplier);
    TentativePropertyChangedEventHandler tentativePropertyChanged = this.TentativePropertyChanged;
    if (tentativePropertyChanged == null)
      return;
    tentativePropertyChanged((object) this);
  }

  private void TxNumericEditBoxMaxContactForce_TentativeValueChanged(
    object sender,
    TxNumericEditBoxCtrl_TentativeValueChangedEventArgs args)
  {
    if (this.IsControlLoading)
      return;
    double num;
    try
    {
      num = (double) new CApNewtonToKillogramConverter().ConvertBack((object) (CApCableUtility.ConvertStringToDouble(this.TxNumericEditBoxMaxContactForce.Text) * TxApplication.Options.Units.MassMultiplier), this.TxNumericEditBoxMaxContactForce.GetType(), (object) this.TxNumericEditBoxMaxContactForce, CultureInfo.CurrentCulture);
    }
    catch (FormatException ex)
    {
      num = 0.0;
    }
    this.AttributeViewModel.SetMaxContactForceNoEventSent(num);
    TentativePropertyChangedEventHandler tentativePropertyChanged = this.TentativePropertyChanged;
    if (tentativePropertyChanged == null)
      return;
    tentativePropertyChanged((object) this);
  }

  private void TxNumericEditBoxMinCurvatuceRadius_TentativeValueChanged(
    object sender,
    TxNumericEditBoxCtrl_TentativeValueChangedEventArgs args)
  {
    if (this.IsControlLoading)
      return;
    this.AttributeViewModel.SetMinCurvatureRadiusNoEventSent(args.TentativeValue * TxApplication.Options.Units.LinearMultiplier);
    TentativePropertyChangedEventHandler tentativePropertyChanged = this.TentativePropertyChanged;
    if (tentativePropertyChanged == null)
      return;
    tentativePropertyChanged((object) this);
  }

  public void StartOfLoading() => this.IsControlLoading = true;

  public void EndOfLoading() => this.IsControlLoading = false;

  [DebuggerNonUserCode]
  [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  public void InitializeComponent()
  {
    if (this._contentLoaded)
      return;
    this._contentLoaded = true;
    Application.LoadComponent((object) this, new Uri("/DnProcessSimulateCommands;component/flexibles/usercontrols/capcableparametersusercontrol.xaml", UriKind.Relative));
  }

  [DebuggerNonUserCode]
  [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  [EditorBrowsable(EditorBrowsableState.Never)]
  void IComponentConnector.Connect(int connectionId, object target)
  {
    switch (connectionId)
    {
      case 1:
        this.parameterStackPanel = (StackPanel) target;
        break;
      case 2:
        this.parameterGrid = (Grid) target;
        break;
      case 3:
        this.densityRow = (RowDefinition) target;
        break;
      case 4:
        this.fulcrumRow = (RowDefinition) target;
        break;
      case 5:
        this.maxTensionRow = (RowDefinition) target;
        break;
      case 6:
        this.maxTwistRow = (RowDefinition) target;
        break;
      case 7:
        this.minCurvatureRadiusRow = (RowDefinition) target;
        break;
      case 8:
        this.passNearRow = (RowDefinition) target;
        break;
      case 9:
        this.oscillationSliderRow = (RowDefinition) target;
        break;
      case 10:
        this.textblockDensity = (TextBlock) target;
        break;
      case 11:
        this.TxNumericEditBoxDensity = (TxNumericEditBoxControl) target;
        ((UIElement) this.TxNumericEditBoxDensity).GotFocus += new RoutedEventHandler(this.TxNumericEditBox_GotFocus);
        this.TxNumericEditBoxDensity.TentativeValueChanged += new TxNumericEditBoxCtrl_TentativeValueChangedEventHandler(this.TxNumericEditBoxDensity_TentativeValueChanged);
        break;
      case 12:
        this.textblockYoungsModulus = (TextBlock) target;
        break;
      case 13:
        this.TxNumericEditBoxYoungsModulus = (TxNumericEditBoxControl) target;
        ((UIElement) this.TxNumericEditBoxYoungsModulus).GotFocus += new RoutedEventHandler(this.TxNumericEditBox_GotFocus);
        this.TxNumericEditBoxYoungsModulus.TentativeValueChanged += new TxNumericEditBoxCtrl_TentativeValueChangedEventHandler(this.TxNumericEditBoxYoungsModulus_TentativeValueChanged);
        break;
      case 14:
        this.labelCableFulcrumLength = (TextBlock) target;
        break;
      case 15:
        this.TxNumericEditBoxFulcrumLength = (TxNumericEditBoxControl) target;
        ((UIElement) this.TxNumericEditBoxFulcrumLength).GotFocus += new RoutedEventHandler(this.TxNumericEditBox_GotFocus);
        this.TxNumericEditBoxFulcrumLength.TentativeValueChanged += new TxNumericEditBoxCtrl_TentativeValueChangedEventHandler(this.TxNumericEditBoxFulcrumLength_TentativeValueChanged);
        break;
      case 16 /*0x10*/:
        this.TxInfoButtonStartFulcumLenght = (TxInfoButton) target;
        break;
      case 17:
        this.tensionGrid = (Grid) target;
        break;
      case 18:
        this.tensionColumn = (ColumnDefinition) target;
        break;
      case 19:
        this.rectTensionViolationColor = (Rectangle) target;
        break;
      case 20:
        this.textblockMaxTension = (TextBlock) target;
        break;
      case 21:
        this.TxNumericEditBoxMaxTension = (TxNumericEditBoxControl) target;
        this.TxNumericEditBoxMaxTension.TentativeValueChanged += new TxNumericEditBoxCtrl_TentativeValueChangedEventHandler(this.TxNumericEditBoxMaxTension_TentativeValueChanged);
        break;
      case 22:
        this.twistGrid = (Grid) target;
        break;
      case 23:
        this.twistColumn = (ColumnDefinition) target;
        break;
      case 24:
        this.rectTwistViolationColor = (Rectangle) target;
        break;
      case 25:
        this.textblockMaxTwist = (CheckBox) target;
        break;
      case 26:
        this.TxNumericEditBoxMaxTwist = (TxNumericEditBoxControl) target;
        this.TxNumericEditBoxMaxTwist.TentativeValueChanged += new TxNumericEditBoxCtrl_TentativeValueChangedEventHandler(this.TxNumericEditBoxMaxTwist_TentativeValueChanged);
        break;
      case 27:
        this.contactForceGrid = (Grid) target;
        break;
      case 28:
        this.contactForceColumn = (ColumnDefinition) target;
        break;
      case 29:
        this.rectContactForceExcessViolationColor = (Rectangle) target;
        break;
      case 30:
        this.textblockMaxContactForce = (CheckBox) target;
        break;
      case 31 /*0x1F*/:
        this.TxNumericEditBoxMaxContactForce = (TxNumericEditBoxControl) target;
        this.TxNumericEditBoxMaxContactForce.TentativeValueChanged += new TxNumericEditBoxCtrl_TentativeValueChangedEventHandler(this.TxNumericEditBoxMaxContactForce_TentativeValueChanged);
        break;
      case 32 /*0x20*/:
        this.curvatureRadiusGrid = (Grid) target;
        break;
      case 33:
        this.curvatureColumn = (ColumnDefinition) target;
        break;
      case 34:
        this.rectBendingViolationColor = (Rectangle) target;
        break;
      case 35:
        this.textblockMinCurvatuceRadius = (CheckBox) target;
        break;
      case 36:
        this.TxNumericEditBoxMinCurvatuceRadius = (TxNumericEditBoxControl) target;
        this.TxNumericEditBoxMinCurvatuceRadius.TentativeValueChanged += new TxNumericEditBoxCtrl_TentativeValueChangedEventHandler(this.TxNumericEditBoxMinCurvatuceRadius_TentativeValueChanged);
        break;
      case 37:
        this.labelCablePassNearFrame = (TextBlock) target;
        break;
      case 38:
        this.frameBoxCtrlPassNearFrameCable = (TxObjEditBoxControl) target;
        ((UIElement) this.frameBoxCtrlPassNearFrameCable).GotFocus += new RoutedEventHandler(this.PassNearFrame_GotFocus);
        ((UIElement) this.frameBoxCtrlPassNearFrameCable).LostFocus += new RoutedEventHandler(this.PassNearFrame_LostFocus);
        break;
      case 39:
        this.sliderOscillationGrid = (Grid) target;
        break;
      case 40:
        this.labelCableOscillation = (TextBlock) target;
        break;
      case 41:
        this.textBlockOscillationNone = (TextBlock) target;
        break;
      case 42:
        this.SliderOscillation = (Slider) target;
        break;
      case 43:
        this.textBlockOscillationFull = (TextBlock) target;
        break;
      default:
        this._contentLoaded = true;
        break;
    }
  }
}
